﻿using MengLin.OOP.DesignPattern.Observer.TearcherPhoneChange.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MengLin.OOP.DesignPattern.Observer.TearcherPhoneChange.Implements
{
    /// <summary>
    /// 具体的观察者学生
    /// </summary>
    public class Student: IObserver
    {
        public Student(string name)
        {
            Name = name;
        }

        public Student(string name, Teacher teacher)
        {
            Name = name;
            Teacher = teacher;
        }

        private Teacher _teacher;
        public Teacher Teacher
        {
            get { return _teacher; }
            set { _teacher = value; }
        }

        private string _name;
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        /// <summary>
        /// 老师的手机号码
        /// </summary>
        private string _tPhone;
        public string TPhone
        {
            get { return _tPhone; }
            set { _tPhone = value; }
        }

        /// <summary>
        /// 同步老师的手机号码
        /// </summary>
        public void Update(object obj) 
        {
            this.TPhone = (string)obj;
        }

        /// <summary>
        /// 显示老师的手机号码
        /// </summary>
        public void Show()
        {
            Console.WriteLine("Name:" + this.Name + "\nTeacher Phone:" + this.TPhone);
            //Console.WriteLine("Name:" + this.Name + "\nTeacher Phone:" + this.Teacher.Phone);
        }
    }
}
